const {
  override,
  fixBabelImports,
  addLessLoader,
  addWebpackAlias,
} = require("customize-cra");
const path = require("path");

const rewiredMap = () => (config) => {
  config.devtool =
    config.mode === "development" ? "cheap-module-source-map" : false;
  return config;
};

module.exports = override(
  //babel-plugin-import: 用于按需加载组件代码和样式的 babel 插件。
  fixBabelImports("import", {
    libraryName: "antd",
    libraryDirectory: "es",
    style: true,
  }),
  //利用less-loader的modifyVars来进行主题配置
  addLessLoader({
    javascriptEnabled: true,
    modifyVars: { "@primary-color": "#0392fe" },
  }),
  addWebpackAlias({
    "@": path.resolve(__dirname, "src"),
  }),
  // 关闭mapSource
  rewiredMap()
);
